package cn.gx.learn.security_boot_jwt_websocket.appiontment.controller;

import cn.gx.learn.security_boot_jwt_websocket.appiontment.controller.vo.AppiontmentReqVO;
import cn.gx.learn.security_boot_jwt_websocket.appiontment.dal.data.AppiontmentDO;
import cn.gx.learn.security_boot_jwt_websocket.appiontment.service.AppiontmentService;
import cn.gx.learn.security_boot_jwt_websocket.springsecurity.dal.UserDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AppiontmentController {

    @Autowired
    private AppiontmentService appiontmentService;

    @PostMapping("/appiont/create")
    public ResponseEntity<String> create(@RequestBody AppiontmentReqVO reqVO){
        String r=appiontmentService.ceateAppiontment(reqVO);
        return  ResponseEntity.ok().body(r);
    }

//    @PostMapping("/appiont/cancel")
//    public ResponseEntity<String>cancel(@RequestParam long appiontmentid){
//        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
//        UserDetail  userDetail = (UserDetail) authentication.getPrincipal();
//        String r=appiontmentService.cancelAppiontment(userDetail.getUser().getId(),appiontmentid);
//        return  ResponseEntity.ok().body(r);
//    }


}
